// 是否记住账号
let name1 = localStorage.getItem("name")
if (name1) {
    document.getElementsByTagName("input")[0].value = name1
    document.getElementById("rem-name").checked = true
}
// 登陆判断
document.getElementById("login").addEventListener("click", function() {
    let name = document.getElementsByTagName("input")[0].value
    let password = document.getElementsByTagName("input")[1].value
    let remName = document.getElementById("rem-name").checked
    console.log(password);
    let hint = document.getElementById("hint")
    if (name != "" && password != "") {
        if (name != "admin" && password != "admin") {
            hint.innerText = "用户名或密码错误"
            hint.style.display = "block"
            setTimeout(() => {
                hint.style.display = "none"
            }, 1500);
        } else {
            hint.innerText = "登陆成功"
            hint.style.backgroundColor = "green"
            hint.style.display = "block"
            setTimeout(() => {
                hint.style.display = "none"
                if (remName == true) {
                    localStorage.setItem("name", name)
                }
                window.location.href = "../index.html"
            }, 1500);
        }
    } else {
        hint.innerText = "用户名或密码不能为空"
        hint.style.display = "block"
        setTimeout(() => {
            hint.style.display = "none"
        }, 1500);
    }
})